package controller;

import java.awt.Point;

import view.GeometryDescriptor;

public class SelectSt extends State {

	public SelectSt(DrawingController controller) 
	{
		super(controller);
	}

	@Override
	public void update(Input input, InputMod mod, Point p) 
	{
		if (input == Input.MD && mod == InputMod.LD)
			updateMD_LD(p);		
	}
	
	private void updateMD_LD(Point p) 
	{
		GeometryDescriptor gDesc = this.controller.getView().pointGeometry(p);
		
		switch (gDesc.getGeoState() )
		{
		case INSIDE:
			this.controller.setState(new DragObjSt(this.controller));
			this.controller.selectObject(gDesc);
			break;
		case OUTSIDE:
			this.controller.setState(new IdleSt(this.controller));
			this.controller.selectObject(new GeometryDescriptor());
			break;
		case CTRLPT:
			this.controller.setState(new DragCtrlSt(this.controller));
			this.controller.selectObject(gDesc);
		}
	}


	@Override
	public void update(Input input, InputMod mod, char letter)
	{
		if ( input == Input.KD )
			updateText(mod, letter);
	}

	private void updateText(InputMod mod, char letter)
	{
		if (mod == InputMod.BACKSP)
			controller.deleteLetter();
		else if (mod == InputMod.SYMBOL)
			controller.insertLetter(letter);
		
	}

	private void insert(char letter) 
	{
		// TODO Auto-generated method stub
		
	}

	private void delete() 
	{
		int i_obj = controller.getView().getSelectedObjDesc().getIndex();
		int i_char = controller.getView().getSelectedObjDesc().getCharIndex();
		
		String text_old = "";
		
	}
	


	

}
